<template>
	<view class="content">
		<u-form :model="address" ref="uForm" label-width="150">
			<u-form-item label="姓名">
				<u-input v-model="address.receiverName" />
			</u-form-item>
			<u-form-item label="手机号码">
				<u-input v-model="address.receiverPhone" />
			</u-form-item>
			<u-form-item label="所在区域">
				<picker mode="region" @change="checkRegion">
					<view>{{address.provinceCity}}</view>
				</picker>
			</u-form-item>
			
			<u-form-item label="所在区域">
				<u-picker mode="region" v-model="show"  :area-code='["13", "1303", "130304"]'></u-picker>
			</u-form-item>
			
			<u-form-item label="详细地址">
				<u-input v-model="address.addressDetail" />
			</u-form-item>
		</u-form>
		<view class="button_warp">
			<u-button type="primary" @click="saveAddress">保存地址</u-button>
		</view>
	</view>
</template>

<script>
	import {baseUrl} from '@/api/base';
	export default {
		data() {
			return {
				addressId:'',
				address: {},
			}
		},
		onLoad() {

		},
		methods: {
			checkRegion(params){
				console.log(params);
			},
			saveAddress() {
				if(!this.addressId){
					let formData = {
						openId:getApp().globalData.openId,
						criteria:{
							...this.address
						}	
					};
					this.request({
						url:baseUrl+'/mini/userAddress/saveMiniUserAddress',
						method:'post',
						data:formData
					}).then(response=>{
						console.log(response);
					})
				}
			}
		}
	}
</script>

<style>
	.content {
		padding-left: 30rpx;
		padding-right: 30rpx;
	}
</style>
